package com.steakliu.event.order.listener;/**
 * @Title:
 * @author 刘牌
 * @date 2022-06-2519:27
 */

import com.steakliu.event.order.event.StockEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * 功能说明：库存监听器
 *
 * <p>
 * Original @Author: steakliu-刘牌, 2022-06-25  19:27
 * <p>
 * Copyright (C)2020-2022  小四的技术之旅 All rights reserved.
 */
@Component
@Slf4j
public class StockListener {

    @Async
    @EventListener(StockEvent.class)
    public void decreaseStock(StockEvent stockEvent) throws InterruptedException {
        Thread.sleep(2000);
        log.info("扣减id为【{}】的商品库存，扣减数量为【{}】",stockEvent.getStockDTO().getCommodityId(),stockEvent.getStockDTO().getNum());
    }
}
